package com.settlement.system.controller;

import com.settlement.system.common.result.Result;
import com.settlement.system.common.util.RequestUtils;
import com.settlement.system.service.SysTjAccountService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author huangrensen
 * @since 2023-10-13
 */
@RestController
@RequestMapping("/api/v1/tjAccount")
@RequiredArgsConstructor
public class SysTjAccountController {

    @Value("${system.config.secret}")
    private String secret;

    @Value("${system.config.appId}")
    private String appId;
    private final SysTjAccountService sysTjAccountService;

    @Operation(summary = "查找图鉴账号密码")
    @GetMapping("/findOne")
    public Result<?> findOne(HttpServletRequest request) {
        Result<?> result = RequestUtils.resolveAppToken(request, secret, appId);
        if (!Result.isSuccess(result)) {
            return result;
        }
        return Result.success(sysTjAccountService.findFirst());
    }
}
